package com.example.volunteeroa.controller;

import com.example.volunteeroa.entity.Division;
import com.example.volunteeroa.entity.RestBean;
import com.example.volunteeroa.repository.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("api/division")
public class DivisonController {
    @Resource
    VenueRepository VERepository;
    @Resource
    OrganizationRepository ORepository;
    @Resource
    VolunteerRepository VRepository;
    @Resource
    OrganizationAllocationRepository OARepository;
    @Resource
    DivisionRepository DRepository;

    @GetMapping()
    public RestBean findAll(){
        List<Division> all = DRepository.findAll();
        return new RestBean(200,"查询成功",all);
    }
    @PostMapping()
    public RestBean add(@RequestBody Division division){
        DRepository.save(division);
        return new RestBean(200,"添加成功",null);
    }
}
